﻿using ESRI.ArcGIS.Display;
using ESRI.ArcGIS.SystemUI;
using System;
using System.Runtime.CompilerServices;
using System.Windows.Forms;
using ESRI.ArcGIS.Controls;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Geodatabase;
using System.Collections.Generic;
using System.Drawing;

namespace PlanningGIS.Framework
{
    /// <summary>
    /// 基础系统框架接口类
    /// </summary>
    public interface IFramework
    {
        /// <summary>
        /// 获取或设置工具按钮控件管理对象
        /// </summary>
        IBarManager BarManager { get; set; }

        /// <summary>
        /// 获取或设置工具按钮容器对象
        /// </summary>
        IDockManager DockManager { get; set; }

        /// <summary>
        /// 获取或设置当前执行的工具对象
        /// </summary>
        ITool Tool { get; set; }

        /// <summary>
        /// 获取或设置当前绑定的地图对象，在ArcGIS自带的OnCreate中可以传递该参数
        /// </summary>
        object Object { get; set; }

        /// <summary>
        /// 获取或设置捕捉的缓冲范围
        /// </summary>
        double SnapTolerance { get; set; }

        /// <summary>
        /// 获取或设置缓冲范围
        /// </summary>
        double Tolerance { get; set; }

        /// <summary>
        /// 获取或设置图层树控件
        /// </summary>
        ITOCControl2 TOCControl { get; set; }

        /// <summary>
        /// 获取或设置工具条按钮容器控件
        /// </summary>
        IToolbarControl ToolbarControl { get; set; }

        /// <summary>
        /// 获取地图布局控件
        /// </summary>
        IPageLayoutControl2 PageLayoutControl { get; }

        /// <summary>
        /// 获取地图控件
        /// </summary>
        IMapControl3 MapControl { get; }

        /// <summary>
        /// 获取当前显示的是否是地图控件
        /// </summary>
        bool IsMapCtrlactive { get; }

        /// <summary>
        /// 获取当前显示的是否是布局控件
        /// </summary>
        bool IsPageLayoutActive { get; }

        /// <summary>
        /// 获取当前显示的是否是三维控件
        /// </summary>
        bool IsSceneCtlActive { get; }

        /// <summary>
        /// 获取或设置主窗体对象
        /// </summary>
        Form MdiForm { get; set; }

        /// <summary>
        /// 绑定系统基础控件
        /// </summary>
        /// <param name="mapControl">地图控件</param>
        /// <param name="pageLayoutControl">布局控件</param>
        /// <param name="sceneControl">三维控件</param>
        /// <param name="activateMapFirst">是否开始激活地图控件</param>
        void BindControls(IMapControl3 mapControl, IPageLayoutControl2 pageLayoutControl, ISceneControl sceneControl, bool activateMapFirst);

        /// <summary>
        /// 激活地图控件
        /// </summary>
        void ActivateMapControl();

        /// <summary>
        /// 激活布局控件
        /// </summary>
        void ActivatePageLayoutControl();

        /// <summary>
        /// 激活三维控件
        /// </summary>
        void ActivateSceneControl();

        /// <summary>
        /// 执行按钮命令操作
        /// </summary>
        /// <param name="pommand">要执行的按钮命令</param>
        void ExecuteCommand(ICommand pommand);

        /// <summary>
        /// 处理主窗体地图、布局、三维容器页选择改变后的相关操作
        /// </summary>
        void RaiseMapPageSwitchEvent();

        /// <summary>
        /// 获取当前屏幕坐标
        /// </summary>
        /// <param name="x">X坐标</param>
        /// <param name="y">Y坐标</param>
        /// <returns></returns>
        Point LocationPoint(int x, int y);

        /// <summary>
        /// 不显示相应图层
        /// </summary>
        /// <param name="datasets"></param>
        void UnVisibleLayersFromMapControl(List<IDataset> datasets);

        /// <summary>
        /// 显示相应图层
        /// </summary>
        /// <param name="datasets"></param>
        void VisibleLayersFromMapControl(List<IDataset> datasets);

        /// <summary>
        /// 移除指定的数据对象
        /// </summary>
        /// <param name="datasets"></param>
        void RemoveLayersFromMapControl(List<IDataset> datasets);

        /// <summary>
        /// 添加图层到地图控件中
        /// </summary>
        /// <param name="layers">图层</param>
        void AddLayersToMapControl(ILayer[] layers);

        /// <summary>
        /// 获取停靠控件中的数据控件
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        object GetControlUserData(string name);

        /// <summary>
        /// 主窗体地图、布局、三维容器页选择改变事件
        /// </summary>
        event OnMapPageSwitchEventHandler OnMapPageSwitchEvent;
    }
}
